import store from '../../store'
import {setLocal} from "../service/auth";
export let initUserType = (data) => {
    console.log(data,'用户属性')
    if (data.loginUserType == '2'){
        return init('initNew','/new/home','user')
    }
    if (data.loginUserType == '3'){
        return init('initCarrier','/carrier/survey','user')
    }
    if (data.loginUserType == '4'){
        return init('initAdvisory','/supermarket/survey','user')
    }
    if (data.loginUserType == '6'){
        return init('initCarrier','/admin/carrier/review')
    }
    if (data.loginUserType == '5') {
        if (data.loginFunctionType == '2'){
            return init('initNew','/admin/new/home')
        }
        if (data.loginFunctionType == '3') {
            return init('initCarrier','/admin/carrier/statistics')
        }
    }
    return init('initNomal','/home')

}


function init(modules,homeUrl,type) {
    return store.dispatch(modules,type || 'admin')
        .then(_=>{
            return setLocal('homeUrl',homeUrl)
        })
}
